import moment from 'moment'
// 公共配置
export let config = {
  data () {
    return {
      checkType: [{
        name: '星级寝室检查',
        id: 1
      },
      {
        name: '违章检查',
        id: 3
      },
      {
        name: '生活检查',
        id: 2
      },
      {
        name: '其他',
        id: 4
      }
      ],
      statusCheckWork: [{
        name: '未开始',
        id: 1
      },
      {
        name: '进行中',
        id: 2
      },
      {
        name: '已完成',
        id: 3
      }
      ],
      starLevels: [{
        name: '一星级',
        value: 1
      }, {
        name: '二星级',
        value: 2
      }, {
        name: '三星级',
        value: 3
      }, {
        name: '四星级',
        value: 4
      }, {
        name: '五星级',
        value: 5
      }, {
        name: '无',
        value: null
      }],
      statusRating: [{
        name: '未开始',
        id: 1
      },
      {
        name: '进行中',
        id: 2
      },
      {
        name: '公示中',
        id: 3
      },
      {
        name: '已完成',
        id: 4
      }
      ]
    }
  }
}
// 分页相关
export let pagination = {
  methods: {
    handleSizeChange (pageSize) {
      this.queryParams.size = pageSize
      this.query()
    },
    handleCurrentChange (pageNum) {
      this.queryParams.page = pageNum
      this.query(pageNum)
    }
  }
}
// 过滤器
export let formatTool = {
  methods: {
    // 时间过滤器
    formatTime (row, column, cellValue, index) {
      if (!cellValue) return ''
      return moment(cellValue).format('YYYY-MM-DD')
    },
    // 寝室成员
    formatDoomMerber (row, column, cellValue, index) {
      if (!cellValue) return ''
      var result = ''
      cellValue.forEach(item => {
        result += `[${item.name}, ${item.sn}],`
      })
      result = result.substring(0, result.length - 1)
      return result
    },
    formatHonorStr (row, column, cellValue, index) {
      if (!cellValue) return ''
      return `荣获全校“${cellValue}”称号`
    },
    formatScoreLevel (row, column, cellValue, index) {
      let level = '差'
      if (cellValue >= 85) {
        level = '优'
      } else if (cellValue >= 75) {
        level = '良'
      } else if (cellValue >= 60) {
        level = '中'
      }
      return `${cellValue}(${level})`
    },
    // 标题英文-->中文
    formatTitle (name) {
      switch (name) {
        case 'checkUserName':
          return '检查人'
        case 'score':
          return '得分'
        default:
          return name
      }
    },
    // 工作项类型
    formatChecktype (row, column, cellValue, index) {
      switch (cellValue) {
        case 1:
          return '星级寝室检查'
        case 2:
          return '生活检查'
        case 3:
          return '违章检查'
        default:
          return '其他'
      }
    },
    // 评比类型
    formatRate (row, column, cellValue, index) {
      console.log(cellValue)
      switch (~~cellValue) {
        case 1:
          return '星级寝室'
        case 2:
          return '校文明寝室'
        default:
          return '校标兵寝室'
      }
    },
    // 状态
    formatStatus (cellValue) {
      switch (~~cellValue) {
        case 2:
          return '进行中'
        case 3:
          return '已完成'
        default:
          return '未开始'
      }
    },
    // 评比状态
    formatRateStatus (cellValue) {
      switch (~~cellValue) {
        case 2:
          return '进行中'
        case 3:
          return '公示中'
        case 4:
          return '已完成'
        default:
          return '未开始'
      }
    },
    formatVioStatus (row, column, cellValue, index) {
      switch (~~cellValue) {
        case 0:
          return '无效'
        case 1:
          return '有效'
      }
    },
    // 性别
    formatGender (row, column, cellValue, index) {
      switch (~~cellValue) {
        case 1:
          return '男'
        case 2:
          return '女'
        default:
          return '未知'
      }
    },
    // 星级
    formatStart (row, column, cellValue, index) {
      switch (~~cellValue) {
        case 1:
          return '一星级'
        case 2:
          return '二星级'
        case 3:
          return '三星级'
        case 4:
          return '四星级'
        case 5:
          return '五星级'
        default:
          return '无'
      }
    },
    // 数据来源
    formatDataForm (row, column, cellValue, index) {
      switch (~~cellValue) {
        case 1:
          return '系统'
        default:
          return '导入'
      }
    }
  }
}
